package frsf.cidisi.exercise.tp.situationCalculus.actions;

import frsf.cidisi.exercise.tp.situationCalculus.Indiana_State;
import frsf.cidisi.exercise.tp.situationCalculus.Isla_Emicere_State;
import frsf.cidisi.faia.agent.situationcalculus.SituationCalculusAction;
import frsf.cidisi.faia.state.AgentState;
import frsf.cidisi.faia.state.EnvironmentState;

public class ViajarA_Mixocu extends SituationCalculusAction {

    @Override
    public EnvironmentState execute(AgentState ast, EnvironmentState est) {
        
    	Isla_Emicere_State environmentState = (Isla_Emicere_State) est;
		Indiana_State agState = ((Indiana_State) ast);

		if (agState.getPosicion().getNombre().equals("Vinizaile")) {

			environmentState.ejecutarPirata();
			environmentState.getworld().getAldea("Mixocu").setVisitada(environmentState.getworld().getAldea("Mixocu").getVisitada() + 1);
			// Update the agent state
			
			((Indiana_State) agState).setPosicion(environmentState.getworld().getAldea("Mixocu"));

			// Update the real world
			environmentState.setpos_agente(agState.getPosicion());

			return environmentState;
		}

		return null;
    }

    @Override
    public String toString() {
        return "ViajarA_Mixocu";
    }
}

